const express = require('express');
const expressStatic = require('express-static');
var server = express();

server.listen(8080);

//接口 /login?username=yuonly&pwd=123
var users ={
    'yuonly':'123123',
    'zhangsan':'666',
    'lisi':'999'
}
server.get('/login',function(req,res){
    //直接获取get参数的对象
    var username = req.query['username'];
    var pwd = req.query['pwd'];
    if(users[username]==null){
        res.send({ok:false,msg:'用户不存在'});
    }else{
        if(users[username]!=pwd){
            res.send({ok:false,msg:'用户名密码错误'});
        }else{
            res.send({ok:true,msg:'登录成功'});
        }
    }
})

// http://localhost:8080/login?username=lisi&pwd=123

//指定去哪儿读 静态文件
server.use(expressStatic('./www'));
